const oBtn = document.querySelector('button')
const username = document.querySelector('[name = name]')
const pwd = document.querySelector('[name = pwd]')
const oP = document.querySelector('p')
// const fs = require('fs')
oBtn.addEventListener('click', () => {
  if (!/^\w{4,10}$/.test(username.value)) {
    oP.innerHTML = '请输入数字/字母/下划线4-10位账号'
    return
  } else {
    oP.innerHTML = ''
  }

  if (!/^\d{6}$/.test(pwd.value)) {
    oP.innerHTML = '请输入六位数密码'
    return
  } else {
    oP.innerHTML = ''
  }
  // let username = getCookie('username')
  // if (username != 'admin') {
  //   oP.innerHTML = '请输入管理员账号'
  //   return
  // }
  setCookie('username', username.value, 7200)
  location.href = '/pages/index.html'
})  